#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "header.h"

void init(){
    int i;
    FILE *fl=fopen("config.txt","r");
    if (fl!=NULL){
        char line[128];
        for(i=0;fgets(line,sizeof(line),fl)!=NULL;i++){
            switch(i){
                case 1:
                    serv_port=atoi(line);
                    break;
                case 3:
                    ip_addr=(char*)malloc(sizeof(char)*16);
                    bzero(ip_addr,sizeof(char)*16);
                    strncpy(ip_addr,line,16);
                    *(ip_addr+strlen(ip_addr)-1)='\0';
                    break;
                case 5:
                    cache_size=atoi(line)*1024;
                    break;
                case 7:
                    cachetime=atoi(line);
            }

            bzero(line,sizeof(line));

        }
    }

}
